<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        <h1>
            <span class="type">Class</span>
            Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter
                <span class="parent">&lt;
                    <a href="BaseReporter.html">Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter</a>
                </span>
        </h1>
        <ul class="files">
            <li><a href="../../../../../files/lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter_rb.html">lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter.rb</a></li>
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    <div class="description">
      
<p><a
href="BaseReporter.html">Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter</a>
subclass giving <a
href="../ExceptionReporting.html">Hoodoo::Services::Middleware::ExceptionReporting</a>
access to Airbrake for error reporting. See <a
href="https://airbrake.io">airbrake.io</a>.</p>

<p>Your application must include the Airbrake gem &#39;airbrake&#39; via
Gemfile (+gem &#39;airbrake&#39;+ / +bundle install) or direct installation
(+gem install airbrake+).</p>

<p>The API key must be set during your application initialization and the
class must be added to <a href="../../../../Hoodoo.html">Hoodoo</a> for use
as an error reporter, e.g. through a &#39;config/initializers&#39; folder,
as follows:</p>

<pre><code>require &#39;airbrake&#39;

Airbrake.configure do | config |
  config.api_key = &#39;YOUR_AIRBRAKE_API_KEY&#39;
end

Hoodoo::Services::Middleware::ExceptionReporting.add(
  Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter
) unless Service.config.env.test? || Service.config.env.development?
</code></pre>

<p><a href="../../../Services.html">Services</a> and the <a
href="../../../../Hoodoo.html">Hoodoo</a> middleware do not pass Rails-like
params around in forms or query strings, but do beware of search or filter
query data containing sensitive material or POST bodies in e.g. JSON
encoding containing sensitive data. This comes down to the filtering
ability of the Airbrake gem:</p>

<pre><code>https://github.com/airbrake/airbrake/wiki/Customizing-your-airbrake.rb
</code></pre>

    </div>








    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
        <dt>C</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-i-contextual_report">contextual_report</a>
              </li>
          </ul>
        </dd>
        <dt>R</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-i-report">report</a>
              </li>
          </ul>
        </dd>
    </dl>










    <!-- Methods -->
      <div class="sectiontitle">Instance Public methods</div>
        <div class="method">
          <div class="title method-title" id="method-i-contextual_report">
              <b>contextual_report</b>( e, context )
            <a href="../../../../../classes/Hoodoo/Services/Middleware/ExceptionReporting/AirbrakeReporter.html#method-i-contextual_report" name="method-i-contextual_report" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Report an exception for errors that occur within a fully handled <a
href="../../../../Rack.html">Rack</a> request context, with a high level
processed <a href="../../../../Hoodoo.html">Hoodoo</a> representation
available.</p>
<dl class="rdoc-list note-list"><dt><code>e</code>
<dd>
<p>Exception (or subclass) instance to be reported.</p>
</dd><dt><code>context</code>
<dd>
<p><a href="../../Context.html">Hoodoo::Services::Context</a> instance
describing an in-flight request/response cycle.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-contextual_report_source')" id="l_method-i-contextual_report_source">show</a>
              </p>
              <div id="method-i-contextual_report_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">contextual_report</span>( <span class="ruby-identifier">e</span>, <span class="ruby-identifier">context</span> )
  <span class="ruby-identifier">opts</span> = {
    <span class="ruby-value">:rack_env</span>         =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">owning_interaction</span>.<span class="ruby-identifier">rack_request</span>.<span class="ruby-identifier">env</span>,
    <span class="ruby-value">:backtrace</span>        =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">caller</span>(),
    <span class="ruby-value">:environment_name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Hoodoo</span><span class="ruby-operator">::</span><span class="ruby-constant">Services</span><span class="ruby-operator">::</span><span class="ruby-constant">Middleware</span>.<span class="ruby-identifier">environment</span>,
    <span class="ruby-value">:session</span>          =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">user_data_for</span>( <span class="ruby-identifier">context</span> ) <span class="ruby-operator">||</span> <span class="ruby-string">&#39;unknown&#39;</span>
  }

  <span class="ruby-constant">Airbrake</span>.<span class="ruby-identifier">notify_or_ignore</span>( <span class="ruby-identifier">e</span>, <span class="ruby-identifier">opts</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-report">
              <b>report</b>( e, env )
            <a href="../../../../../classes/Hoodoo/Services/Middleware/ExceptionReporting/AirbrakeReporter.html#method-i-report" name="method-i-report" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Report an exception to Airbrake.</p>
<dl class="rdoc-list note-list"><dt>e
<dd>
<p>Exception (or subclass) instance to be reported.</p>
</dd><dt>env
<dd>
<p>Optional <a href="../../../../Rack.html">Rack</a> environment hash for the
inbound request, for exception reports made in the context of <a
href="../../../../Rack.html">Rack</a> request handling. In the case of
Airbrake, the call may just hang unless a <a
href="../../../../Rack.html">Rack</a> environment is provided.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-report_source')" id="l_method-i-report_source">show</a>
              </p>
              <div id="method-i-report_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">report</span>( <span class="ruby-identifier">e</span>, <span class="ruby-identifier">env</span> )
  <span class="ruby-identifier">opts</span> = { <span class="ruby-value">:backtrace</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">caller</span>() }
  <span class="ruby-identifier">opts</span>[ <span class="ruby-value">:rack_env</span> ] = <span class="ruby-identifier">env</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">nil?</span>

  <span class="ruby-constant">Airbrake</span>.<span class="ruby-identifier">notify_or_ignore</span>( <span class="ruby-identifier">e</span>, <span class="ruby-identifier">opts</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
</div>

    </div>
  </body>
</html>
